/*
 * $Id$
 */

package corejs.rt;

import static corejs.rt.Undefined.UNDEFINED;

/**
 *
 * @author pengyu
 */
public class Arguments extends Obj implements ArrayAccessSupport {

   private Value[] _array;
   
   public Arguments(final Value[] array, final Invocable fn) {
      super(null);
      _array = array;
      store("length", _array.length);
      store("callee", fn);
   }

   @Override
   public Value resolve(final int index) {
      return (index < 0 || index >= _array.length) ? UNDEFINED : _array[index];
   }

   public int length() {return _array.length;}
}
